'use strict'
require('./index.scss')
require('page/common/nav/index.js')
require('page/common/header/index.js')
var navSide = require('page/common/nav-side/index.js')
// 通用的JS工具封装
var _wm = require('util/wm.js')
// 用户服务
var _user = require('service/user-service.js')

var templateIndex = require('./index.string')


var page = {
    init: function(){
        this.onLoad()
    },

    onLoad: function(){
        // 初始化左侧菜单
        navSide.init({
            name: 'user-center'
        })
        this.loadUserInfo()
    },

    // 加载个人中心-用户信息
    loadUserInfo: function(){
        var userHtml = ''

        _user.getUserInfo(function(res){
            userHtml = _wm.render(templateIndex, res)
            $('.panel_body').html(userHtml)
        }, function(errMsg){
            _wm.errorTips(errMsg)
        })
    }
}

$(function(){
    page.init()
})